package com.atguigu.srb.core.controller.api;


import com.atguigu.common.result.R;
import com.atguigu.srb.base.utils.JwtUtils;
import com.atguigu.srb.core.pojo.entity.LendItemReturn;
import com.atguigu.srb.core.service.LendItemReturnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 标的出借回款记录表 前端控制器
 * </p>
 *
 * @author tjf
 * @since 2022-01-03
 */
@RestController
@Slf4j
@Api(tags = "回款计划")
@RequestMapping("api/core/lendItemReturn")
public class LendItemReturnController {
    private final LendItemReturnService lendItemReturnService;

    public LendItemReturnController(LendItemReturnService lendItemReturnService) {
        this.lendItemReturnService = lendItemReturnService;
    }

    @ApiOperation("获取列表")
    @GetMapping("/list/{lendId}")
    public R list(@ApiParam("标的id") @PathVariable Long lendId, @RequestHeader String token) {
        Long userId = JwtUtils.getUserId(token);
        List<LendItemReturn> list = lendItemReturnService.listByLendId(lendId, userId);
        return R.ok().data("list", list);
    }
}

